const CommomUtil = require('../utils/CommomUtil');
const SessionUtil = require('../utils/SessionUtil');
const redis_session = require('../config').redis_user;
const albums_dao = require('../dao/albums_dao');
const user_dao = require('../dao/user_dao');
const music_dao = require('../dao/music_dao');

/** 首页 推荐 */
module.exports.home_page = home_page;
async function home_page(ctx) {
    let { ty_id, ty_s_id } = CommomUtil.getReqData(ctx);
    let resData = {};
    if (CommomUtil.inValid(ty_id, 32) || CommomUtil.isEmpty(ty_s_id)) {
        resData['ret'] = false;
        resData['msg'] = '参数不全!';
        return ctx.body = resData;
    }
    // if (!(await SessionUtil.checkTySession(ty_id, ty_s_id))) {
    //     resData['ret'] = false;
    //     resData['msg'] = '请先登录!';
    //     return ctx.body = resData;
    // }
    /** 推荐单曲 */
    let music_list = await music_dao.query_recommend_music_list(3);
    let play_list = await albums_dao.query_recommend_play_list(1, 3);
    let albums_list = await albums_dao.query_recommend_play_list(0, 3);
    resData['music_list'] = music_list;
    resData['play_list'] = play_list;
    resData['albums_list'] = albums_list;
    resData['ret'] = true;
    resData['msg'] = '查询成功!';
    return ctx.body = resData;
}